package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.service.DelDepService;
import com.jx.servicrimpl.DelDepServiceimpl;
/**
 * 删除部门
 * @author zzzzzzz
 *
 */
public class DelDepController extends HttpServlet{
	DelDepService dds=new DelDepServiceimpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//获取数据
		String strIds=req.getParameter("strIds");
		//分割
		String[] deps=strIds.split(",");
		int m=0;
		//循环转化，删除
		for(int i=0;i<deps.length;i++){
			int j=Integer.parseInt(deps[i]);
			if(dds.delDepService(j)==true){
				m++;
			}else{
				break;
			}
		}
		//传回数据
		PrintWriter pw=resp.getWriter();
		if(m==deps.length){
			pw.write("1");
		}else{
			pw.write("0");
		}
	}
}
